import { defineStore } from "pinia"
import type { UserInfoState, UserInfo, UserPermissions } from "@/types/userInfo"
export const useUserInfoStore = defineStore("useUserInfoStore", {
	state: () : UserInfoState => {
		return {
			userInfo: {
				nickName: '',
				dept: {}
			},
			token: '',
			permissions: []
		}
	},
	getters: {
		getUserInfo() : UserInfo {
			return this.userInfo
		},
		getToken() : string {
			return this.token
		},
		getPermissions(): UserPermissions {
			return this.permissions
		},
	},
	actions: {
		setUserInfo(payload : UserInfo) {
			this.userInfo = payload
		},
		setToken(payload : string) {
			this.token = payload
		},
		setPermissions(payload : UserPermissions) {
			this.permissions = payload
		},
	}
})